<template>
  <el-dialog
    class="app-dialog normal-dialog"
    :visible.sync="showDialog"
    :title="title"
    :width="width"
    :show-close="!isValidete"
    :close-on-click-modal="false"
    :append-to-body="isAppend"
  >
    <template #title>
      <div class="validate-title">
        <span class="title-txt">{{ title }}</span>
        <span v-if="isValidete" class="validate-txt">
          <i class="va-icon">*</i> 为必填</span
        >
      </div>
    </template>
    <el-scrollbar  class="app-dialog-container" :style="{
      height: $attrs['dialog-prop'].height || 'auto'
    }"> 
      <slot name="dialog-content"></slot>
    </el-scrollbar>
    <div slot="footer" class="dialog-footer">
      <el-button v-if="close" @click="showDialog = false">{{
        close
      }}</el-button>
      <el-button
        v-if="submit"
        type="primary"
        :loading="loading"
        @click="handleSubmit"
        >{{ submit }}</el-button
      >
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "normalDialog",
  inheritAttrs: false,
  data() {
    return {
      width: this.$attrs["dialog-prop"].width || "600px",
      close: this.$attrs["dialog-prop"].close || null,
      // isAppend: this.$attrs["dialog-prop"].isAppend || false,
      isAppend: false,
      showDialog: false,
      loading: false,
    };
  },
  computed: {
    isValidete() {
      return false;
    },
    title() {
      return this.$attrs["dialog-prop"].title || "默认标题";
    },

    submit() {
      return this.$attrs["dialog-prop"].submit || null;
    },
  },
  methods: {
    handleSubmit() {
      let _self = this;
      _self.loading = true;
      _self.$emit("normal-submit");
    },
  },
};
</script>
<style scoped lang="scss">
.validate-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f2f2f2;
  padding-bottom: 20px;
  .title-txt {
    color: #444;
    font-size: vh(13);
    // font-weight: 600;
  }
  .validate-txt {
    font-size: 12px;
    color: #999;
    position: relative;
    padding-left: 10px;
    .va-icon {
      color: #ff4949;
      position: absolute;
      left: 0;
      top: 25%;
    }
  }
}
</style>